//
//  TitleButton.swift
//  WeiBoDemo
//
//  Created by mac on 2017/11/20.
//  Copyright © 2017年 mac. All rights reserved.
//

import UIKit

class TitleButton: UIButton {

    //MARK:- 重写init函数
    override init(frame: CGRect){
        super.init(frame : frame)
        self.setImage(UIImage.init(named: "navigationbar_arrow_down"), for: .normal)
        self.setImage(UIImage.init(named: "navigationbar_arrow_up"), for: .selected)
        self.setTitle("coderwhy", for: .normal)
        self.sizeToFit()
    }

    //swift中规定 ：重写控件的init（frame方法）或者init（）方法，必须重写init？（）
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        titleLabel!.frame.origin.x = 0
        imageView!.frame.origin.x = titleLabel!.frame.size.width + 5
    }
}
